package cn.virde.example.javafx.textfield;

import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;

import java.net.URL;
import java.util.ResourceBundle;

public class TextFieldController implements Initializable {

    @FXML
    private TextField testTextField;

    @FXML
    private TextField textField2;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        testTextField.addEventFilter(EventType.ROOT, new EventHandler<Event>() {
            @Override
            public void handle(Event event) {
                System.out.println("T1:"+event.getEventType().getName());
            }
        });
        textField2.addEventHandler(EventType.ROOT, new EventHandler<Event>() {
            @Override
            public void handle(Event event) {
                System.out.println("T2:"+event.getEventType().getName());
            }
        });
    }

}
